#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/module.h>

#include "khook/engine.c"
// int vfs_create(struct inode *, struct dentry *, umode_t, bool);
KHOOK(vfs_create);
static int khook_vfs_create(struct inode* a, struct dentry* b, umode_t d,
                            bool c)
{
    int ret;
    ret = KHOOK_ORIGIN(vfs_create, a, b, d, c);
    printk("vfs_create:%s\n", b->d_name.name);
    return ret;
}

KHOOK(vfs_link);
// int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode
// **);
static int khook_vfs_link(struct dentry* a, struct inode* b, struct dentry* c,
                          struct inode** d)
{
    int ret;
    ret = KHOOK_ORIGIN(vfs_link, a, b, c, d);
    printk("vfs_link:%s\n", c->d_name.name);
    return ret;
}

// int vfs_mkdir(struct inode *, struct dentry *, umode_t);
KHOOK(vfs_mkdir);
static int khook_vfs_mkdir(struct inode* a, struct dentry* b, umode_t c)
{
    int ret;
    ret = KHOOK_ORIGIN(vfs_mkdir, a, b, c);
    printk("vfs_mkdir:%s\n", b->d_name.name);
    return ret;
}

// int vfs_rmdir(struct inode *, struct dentry *);
KHOOK(vfs_rmdir);
static int khook_vfs_rmdir(struct inode* a, struct dentry* b)
{
    int ret;
    ret = KHOOK_ORIGIN(vfs_rmdir, a, b);
    printk("vfs_rmdir:%s\n", b->d_name.name);
    return ret;
}

KHOOK(vfs_unlink);
// int vfs_unlink(struct inode *, struct dentry *, struct inode **);
static int khook_vfs_unlink(struct inode* a, struct dentry* b, struct inode** c)
{
    int ret;
    ret = KHOOK_ORIGIN(vfs_unlink, a, b, c);
    printk("vfs_unlink:%s\n", b->d_name.name);
    return ret;
}

int init_module(void)
{
    printk("khook_init\n");
    return khook_init();
}

void cleanup_module(void)
{
    printk("khook_cleanup\n");
    khook_cleanup();
}

MODULE_LICENSE("GPL\0but who really cares?");